
<%@ page isELIgnored="false" language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="fmt" 
           uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	
	<script type="text/javascript" src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
	<style>
		.selectinput
		{
			width:350px;
		}
	</style>
<title>Insert title here</title>
</head>
<body>
	<p>欢迎${sessionScope.name}</p>
	<a href="${pageContext.request.contextPath }/user/car"><button>购物车</button></a>
	<a href="${pageContext.request.contextPath }/user/toMyOrder"><button>查看订单</button></a>
	<a href="${pageContext.request.contextPath }/user/logout"><button>登出</button></a>
	<form action="${pageContext.request.contextPath }/goods/consumeselectbycol" method="post">
	查询条件：
		<table width="100%" border=1 >
			<tr>
				<td><input type="submit" value="查询"/></td>
				<td><label>商品类型:</label><input class="selectinput"  type="text" name="type.typename" /></td>
				<td><label>商品状态:</label><input class="selectinput"  type="text" name="goods.status" /></td>
				<td><label>商品名字:</label><input class="selectinput"  type="text" name="goods.name"/></td>
			</tr>
		</table>
	</form>

	
上架商品列表：
	<table width="100%" border=1 style="text-align:center">
		<tr>
			<td>商品名字</td>
			<td>商品类型</td>
			<td>商品价格</td>
			<td>生产日期</td>
			<td>有效期(限食品)</td>
			<td>生产商(限食物和衣服)</td>
			<td>出版社(限书本)</td>
			<td>尺码(限衣服)</td>
			<td>数量</td>
			<td>下架日期</td>
			<td>商品优惠信息</td>
			<td>商品状态</td>
			<td>操作</td>
		</tr>
	<c:if test="${enhanceList!=null}">
		<c:forEach items="${enhanceList}" var="enhance">
			<tr>
				<td>${enhance.goods.name}</td>
				<td>${enhance.type.typename}</td>
				<td>${enhance.goods.price}元</td>
				<td><fmt:formatDate value="${enhance.goods.prodate}" pattern="yyyy-MM-dd"/></td>
				<td><fmt:formatDate value="${enhance.goods.effdate}" pattern="yyyy-MM-dd"/></td>
				<td>${enhance.goods.producer}</td>
				<td>${enhance.goods.publisher}</td>
				<td>${enhance.goods.size}</td>
				<td>${enhance.goods.num}</td>
				<td>${enhance.goods.outdate}</td>
				<td>${enhance.discountsMessage.describe}</td>
				<td class="status">${enhance.goods.status}</td>
				<td>
					<button onclick="insertCar(${enhance.goods.id})">加入购物车</button>
				</td>
			</tr>
		</c:forEach>
	</c:if>
	</table>


<script>
	
	function insertCar(id)
	{	
		var num=$.trim(prompt("请输入商品数量"));
		if(num==''||num==null)
		{
			alert("加入购物车失败,需要输入商品数量");
			return;
		}
		$.ajax({
			url:"${pageContext.request.contextPath }/user/insertCar?goodsnum="+num+"&goodsid="+id,
			async:true,
			success:function()
			{
				alert("商品成功加入购物车");
			}
		});
		
	}
	
	
	
</script>
	
</body>
</html>